// If $.spro is not already defined
// then create and configure it.
if (!$.spro) {
    $.spro = {};
}

// If the toolbar is not already defined
// then create and configure it.
if (!$.spro.toolbar) {
    try {
        var tbar = $.spro.toolbar = {},
            test = 1;

        tbar.load = function(params, position) {
            // Check to see if params is defined.
            // If not, then why exactly are we being
            // called...?
            if (params && typeof params === "object") {
                // Start CORE - - - - - >
                
                // If we aren't given specific values then
                // provide defaults. Note however, some
                // params are required.
                var _id = params["id"] || "spro-toolbar-container",
                    _theme = params["theme"] || "default";
                
                // Important variables
                var theme = {
                    "default": {
                        "textShadow": "1px 1px 5px",
                        "color": "#FFFFFF",
                        "acolor": "yellow",
                        "startBGcolor": "#8C0000",
                        "endBGcolor": "#650000",
                    }
                },
                    toolbar = $('' + 
                        '<center><div id="' + _id + '">' +
                                '<img id="spro-toolbar-toggle" src="http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/32/Arrow-icon.png" />' +
                            '<div id="spro-toolbar-content">' +
                                'Hello!' +
                            '</div>' +
                        '</div></center>'
                    +'').prependTo("body"),
                    th = theme[_theme];
                
                // Set up basic css template for toolbar container...
                $('<style type="text/css">' +
                    '#spro-toolbar-container {' +
                        'text-align: left;' +
                        'color:' + th["color"] + ';' +
                        'width: 95%;' + 'min-width: 500px;' + 'height: 100px;' +
                        'background-color: black;' +                  
                        'margin: auto;' +
                        'padding: 0px;' +
                        'position: fixed;' +
                        'bottom: 0px;' +
                        'overflow: hidden;' +
                    '}' +
                 // ... and its content.
                    '#spro-toolbar-content {' +
                        'width: 100%;' + 'height: 50px;' +
                        'background-color:' + th["startBGcolor"] + ';' +
                        'background-image: -moz-linear-gradient(top, ' + th["startBGcolor"] + ', ' + th["endBGcolor"] + ');' +
                        'background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, ' + th["startBGcolor"] + '),color-stop(1, ' + th["endBGcolor"] + '));' +
                        'background-image: -webkit-linear-gradient(' + th["startBGcolor"] + ', ' + th["endBGcolor"] + ');' +
                        'margin: auto;' +
                        'margin-top: 30px;' + 
                        'padding: 10px;' +
                        'padding-bottom: 0px' +
                        'overflow: hidden;' +
                        'cursor: default;' +
                        '-moz-box-shadow: 0px 0px 10px #000;' +
                        '-webkit-box-shadow: 0px 0px 10px #000;' +
                        'box-shadow: 0px 0px 10px #000;' + 
                        '-moz-border-radius-topleft: 10px; ' +             
                        '-moz-border-radius-topright: 10px; ' +
                        '-webkit-border-top-left-radius: 10px; ' +
                        '-webkit-border-top-right-radius: 10px;' +
                        'border-top-left-radius: 10px;' +
                        'border-top-right-radius: 10px;' +
                    '}' +
                    
                    '#spro-toolbar-toggle {' +
                        'position: absolute;' +
                        'top: 10px; right: 0px;' +
                    '}' +
                '</style>').appendTo("head");
                
                // Finally, insert the toolbar into the page
                $("body").append(toolbar);

                // End CORE - - - - - >
            } else {
                // Let's try to give a specific reason on
                // why the toolbar wasn't configured
                // correctly.
                if (!params) {
                    return undefined;
                } else if (typeof params !== "object") {
                    return "Params Must be an Object!";
                };
            }
        }; // End "tbar.load"
    } catch (e) {
        alert(e);
    } // End "try-catch"
} // End "spro.toolbar"

$.spro.toolbar.load({"e":"e"});